import java.util.*;

/**
 * @Author 12629
 * @Description：
 */
public class Test {

    public static void main(String[] args) {
        Deque<Integer> deque = new LinkedList<>();
        deque.offer(1);
        Deque<Integer> stack = new LinkedList<>();
        stack.push(10);
        Stack<Integer> stack1 = new Stack<>();
        Deque<Integer> stack2 = new ArrayDeque<>();//数组
    }

    public static void main4(String[] args) {
        MyQueue queue = new MyQueue();
        queue.offer(1);
        queue.offer(2);
        int val = queue.poll();//1
        System.out.println(val);
        int val2 = queue.peek();//2
        System.out.println(val2);
    }

    public static void main3(String[] args) {
        Queue<Integer> queue = new LinkedList<>();
        queue.offer(1);
        queue.offer(2);
        int val = queue.poll();
        System.out.println(val);
        int val2 = queue.peek();
        System.out.println(val2);
    }

    public boolean IsPopOrder(int [] pushA,int [] popA) {
        Stack<Integer> stack = new Stack<>();
        int j = 0;//变量popA这个数组
        for (int i = 0; i < pushA.length; i++) {
            stack.push(pushA[i]);
            while (!stack.empty() && j < popA.length
                    && stack.peek() == popA[j]) {
                stack.pop();
                j++;
            }
        }
        return stack.empty();
    }

    public int evalRPN(String[] tokens) {

        Stack<Integer> stack = new Stack<>();

        for(String s : tokens) {
            if(!isOpera(s)) {
                //数字 ：放入栈当中
                stack.push(Integer.parseInt(s));
            }else {
                //弹出栈顶的2个元素
                int num2 = stack.pop();
                int num1 = stack.pop();
                switch(s) {
                    case "+" :
                        stack.push(num1+num2);
                        break;
                    case "-" :
                        stack.push(num1-num2);
                        break;
                    case "*" :
                        stack.push(num1*num2);
                        break;
                    case "/" :
                        stack.push(num1/num2);
                        break;
                }
            }
        }
        return stack.pop();
    }


    public boolean isOpera(String x) {
        if(x.equals("+") || x.equals("-") ||  x.equals("*")
                || x.equals("/")) {
            return true;
        }
        return false;
    }
    public static void main2(String[] args) {
        MyStack myStack = new MyStack();
        myStack.push(1);
        myStack.push(2);
        myStack.push(3);
        myStack.push(4);
        System.out.println("====");

        System.out.println(myStack.peek());
        System.out.println(myStack.peek());
    }
    public static void main1(String[] args) {
        //底层是一个数组  ！！！  链表能不能实现栈？？可以的！！
        Stack<Integer> stack = new Stack<>();
        stack.push(12);
        stack.push(23);
        stack.push(34);

        //将元素弹出！ 【删除栈顶元素的】
        int x = stack.pop();
        System.out.println(x);

        //只是获取当前的栈顶元素是什么？
        int x2 = stack.peek();
        System.out.println(x2);

        System.out.println(stack.empty());

        //ArrayDequeue
    }
}
